/*
 * @Author: your name
 * @Date: 2023-10-11 13:03:45
 * @LastEditTime: 2023-10-23 10:13:47
 * @LastEditors: Please set LastEditors
 * @Descripttion: In User Settings Edit
 * @FilePath: /bicycle-mobile-old/h5/src/pages/likeExhibitionList/index.jsx
 */
import React, { useEffect, } from 'react'
import styles from './index.less'
import InViewPort from '../../components/InViewPort'
import ExhibitorCard from '../../components/exhibitorCard'
import { useDispatch, useSelector } from 'dva'
import ReturnIndex from "../../components/returnIndex"

function Index() {
  const dispatch = useDispatch()
  const {
    likeExhibitorList,
    userInfo
  } = useSelector(({ index }) => index)
  useEffect(() => {
    dispatch({
      type: 'index/apiGetLikeExhibitorList',
      payload: {
        objectType: 'EXHIBITOR',
        type:'COLLECTED',
        userId: userInfo?.user?.id
      }
    })
  }, [])

  function onExEnter() {
    console.log('onExEnter')
  }
  return (
    <div className={styles.page}>
       <ReturnIndex/>
      <div className={styles.exhibitor}>
        {
          likeExhibitorList.map((item, index) => {
            const lestIndex = likeExhibitorList.length - 1
            if (index == lestIndex) {
              return <InViewPort key={index} onEnter={onExEnter}>
                <ExhibitorCard obj={item.object} />
              </InViewPort>
            }
            return <ExhibitorCard obj={item.object} key={index} />
          })
        }
      </div>
    </div>
  )
}

export default Index
